#ifndef VQC_VQC_H
#define VQC_VQC_H

#include <time.h>
#include <stdbool.h>

typedef struct {
    bool yk_switch;

    char *capacitor_name;

    double quantity;
    double reserve0;
    double reserve1;
    double reserve2;
    double reserve3;
    double reserve4;
    double reserve5;
    double reserve6;
    double reserve7;
    double reserve8;
    double reserve9;

    int id;
    int yx_status;
    int status_link;
    int yx_vqc;
    int vqc_link;
    int switch_link;
} capacitor_t;

typedef struct {

    bool yt_idle;

    char *svg_name;

    double quantity;
    double svg_kp;
    double yc_reactive_power;
    double reserve0;
    double reserve1;
    double reserve2;
    double reserve3;
    double reserve4;
    double reserve5;
    double reserve6;
    double reserve7;
    double reserve8;
    double reserve9;

    int id;
    int yx_status;
    int status_link;
    int yx_run;
    int run_link;
    int yx_atresia;
    int artresia_link;
    int reactive_power;
    int idle_link;
} svg_t;

typedef struct {
    char *side_name;

    double yc_reactive_factor;
    double yc_power_factor;
    double reserve0;
    double reserve1;
    double reserve2;
    double reserve3;
    double reserve4;
    double reserve5;
    double reserve6;
    double reserve7;
    double reserve8;
    double reserve9;

    int id;
    int trans_id;
    int yx_switch1;
    int switch1;
    int yx_switch2;
    int switch2;
    int reactive_power;
    int power_factor;
} trans_side_t;

typedef struct {
    char *reactor_name;

    double quantity;
    double reserve0;
    double reserve1;
    double reserve2;
    double reserve3;
    double reserve4;
    double reserve5;
    double reserve6;
    double reserve7;
    double reserve8;
    double reserve9;

    int id;
    int yx_status;
    int yx_fault;
    int yk_switch;
    int status_link;
    int fault_link;
    int switch_link;
} reactors_t;

typedef struct {
    bool yk_up;
    bool yk_down;

    char *trans_name;

    int id;
    int level;
    int level_link;
    int yc_level;
    int up_link;
    int down_link;
    int yx_status;
    int status_link;

    double quantity;
    double reserve0;
    double reserve1;
    double reserve2;
    double reserve3;
    double reserve4;
    double reserve5;
    double reserve6;
    double reserve7;
    double reserve8;
    double reserve9;

    int trans_side_size;
    trans_side_t **trans_side;
} trans_t;


//母线
typedef struct {

    bool is_use;

    char *voltage_level;
    char *bus_name;

    double up_line;
    double down_line;
    double yc_voltage;
    double reserve0;
    double reserve1;
    double reserve2;
    double reserve3;
    double reserve4;
    double reserve5;
    double reserve6;
    double reserve7;
    double reserve8;
    double reserve9;

    int voltage_link;
    int id;

    int trans_size;
    trans_t **trans;
    int capacitor_size;
    capacitor_t **capacitor;
    int reactor_size;
    reactors_t **reactors;
    int svg_size;
    svg_t **svg;
} bus_t;

int parse_json(const cJSON *json, bus_t *ptr);

bus_t *bus_new();

void bus_free(bus_t *bus);

int print_json(cJSON *json, bus_t *bus);

#endif //VQC_VQC_H
